import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { AdjustDetailForm, AdjustForm, AdjustQuery, AdjustVO } from "@/api/fill/adjust/types";

/**
 * 查询预算调整主列表
 * @param query
 * @returns
 */

export const listAdjust = (query?: AdjustQuery) => {
  return request({
    url: "/fill/adjust/list",
    method: "post",
    data: query
  });
};

/**
 * 查询预算调整主详细
 * @param id
 */
export const getAdjust = (id: string | number): AxiosPromise<AdjustVO> => {
  return request({
    url: "/fill/adjust/" + id,
    method: "get"
  });
};
/**
 * 查询预算调整从详细
 * @param id
 */
export const getAdjustDetail = (id: string | number): AxiosPromise<AdjustVO> => {
  return request({
    url: "/fillAdjustDetail/" + id,
    method: "get"
  });
};
/**
 * 修改
 * @param data
 */
export const updateDetail = (data?: AdjustDetailForm) => {
  return request({
    url: "/fillAdjustDetail/updateDetail",
    method: "post",
    data: data
  });
};


/**
 * 新增预算调整主
 * @param data
 */
export const addAdjust = (data: AdjustForm) => {
  return request({
    url: "/fill/adjust",
    method: "post",
    data: data
  });
};

/**
 * 修改预算调整主
 * @param data
 */
export const updateAdjust = (data: AdjustForm) => {
  return request({
    url: "/fill/adjust",
    method: "put",
    data: data
  });
};

/**
 * 删除预算调整主
 * @param id
 */
export const delAdjust = (id: string | number | Array<string | number>) => {
  return request({
    url: "/fill/adjust/" + id,
    method: "delete"
  });
};

export const listDetail = (query?: AdjustQuery) => {
  return request({
    url: "/fill/adjust/listDetail",
    method: "post",
    data: query
  });
};

/*添加明细*/
export const saveDetail = (data?: AdjustDetailForm) => {
  return request({
    url: "/fill/adjust/saveDetail",
    method: "post",
    data: data
  });
};


/**
 * 删除预算调整主
 * @param id
 */
export const deleteDetail = (id: number) => {
  return request({
    url: "/fill/adjust/deleteDetail/" + id,
    method: "get"
  });
};


//上传文件
export const uploadApplyFile = (data?: any) => {
  return request({
    url: "/fill/adjust/uploadFile",
    method: "post",
    data: data
  });
};
//删除文件
export const deleteFile = (ossId?: any) => {
  return request({
    url: "/fill/adjust/deleteFile/" + ossId,
    method: "get",
    params: ossId
  });
};
